package com.hzit.hzb.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.errorprone.annotations.Var;
import com.hzit.hzb.core.pojo.entity.UserLoginRecord;
import com.hzit.hzb.core.mapper.UserLoginRecordMapper;
import com.hzit.hzb.core.service.UserLoginRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.Function;

/**
 * <p>
 * 用户登录记录表 服务实现类
 * </p>
 *
 * @author hbxfwf
 * @since 2024-08-27
 */
@Service
public class UserLoginRecordServiceImpl extends ServiceImpl<UserLoginRecordMapper, UserLoginRecord> implements UserLoginRecordService {

	//1. 根据用户id查询用户日志
	@Override
	public List<UserLoginRecord> userLoginRecord(Long id) {
		LambdaQueryWrapper<UserLoginRecord> lambdaQueryWrapper = Wrappers.<UserLoginRecord>query().lambda().eq(UserLoginRecord::getUserId, id);



		return this.list(
				new QueryWrapper<UserLoginRecord>()
						.eq("user_id", id)
						.orderByDesc("create_time")
						.last(" limit 50")
		);
	}
}
